<?php 

namespace app\App\validate;

use think\Validate;
use plugin\saiadmin\basic\BaseValidate;

class UserValidate extends BaseValidate {

    /**
     * 定义验证规则
     */
    protected $rule =   [
        'username' => 'require',
        'password' => 'require',
        'email' => 'email',
        'phone' => 'mobile',
        'captcha' => 'require',
        "code" => "require",
        "uuid" => "require",
        "type" => "require",
        "scene" => "require",
        'newNickName' => 'require|length:1,60'
    ];

    /**
     * 定义错误信息
     */
    protected $message  =   [
        'username' => 'user.validate.username',
        'password' => 'user.validate.password',
        'email' => 'user.validate.email',
        'phone' => 'user.validate.phone',
        'captcha' => 'user.validate.captcha',
        "code" => 'user.validate.code',
        "uuid" => 'user.validate.uuid',
        "type" => 'user.validate.type',
        "scene" => 'user.validate.scene',
        'newNickName.require' => 'user.validate.newNickNameRequire',
        'newNickName.length' => 'user.validate.newNickNameTooLong',
    ];

    /**
     * 定义场景
     */
    protected $scene = [
        'loginCaptcha' => [
            'email',
            'phone',
            'captcha',
            'code',
            'uuid',
        ],
        'login' => [
            'username',
            'password',
            'code',
            'uuid',
        ],
        'register' => [
            'email',
            'phone',
            'password',
            'captcha',
            'code',
            'uuid',
        ],
        'captcha' => [
            'type',
            'scene',
            'code',
            'uuid',
            'email',
            'phone',
        ],
        'resetPwd' => [
            'email',
            'phone',
            'password',
            'captcha',
            'code',
            'uuid',
        ],
        'newNickName' => [
            'newNickName'
        ]
    ];

}
